package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Hospitalization;
import com.g8.pethospitallearnbackend.entity.HospitalizationExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface HospitalizationMapper {
    @SelectProvider(type=HospitalizationSqlProvider.class, method="countByExample")
    long countByExample(HospitalizationExample example);

    @DeleteProvider(type=HospitalizationSqlProvider.class, method="deleteByExample")
    int deleteByExample(HospitalizationExample example);

    @Delete({
        "delete from hospitalization",
        "where hos_id = #{hosId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String hosId);

    @Insert({
        "insert into hospitalization (hos_id, hos_pet, ",
        "hos_record)",
        "values (#{hosId,jdbcType=VARCHAR}, #{hosPet,jdbcType=LONGVARCHAR}, ",
        "#{hosRecord,jdbcType=LONGVARCHAR})"
    })
    int insert(Hospitalization record);

    @InsertProvider(type=HospitalizationSqlProvider.class, method="insertSelective")
    int insertSelective(Hospitalization record);

    @SelectProvider(type=HospitalizationSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="hos_id", property="hosId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="hos_pet", property="hosPet", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="hos_record", property="hosRecord", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Hospitalization> selectByExampleWithBLOBs(HospitalizationExample example);

    @SelectProvider(type=HospitalizationSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="hos_id", property="hosId", jdbcType=JdbcType.VARCHAR, id=true)
    })
    List<Hospitalization> selectByExample(HospitalizationExample example);

    @Select({
        "select",
        "hos_id, hos_pet, hos_record",
        "from hospitalization",
        "where hos_id = #{hosId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="hos_id", property="hosId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="hos_pet", property="hosPet", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="hos_record", property="hosRecord", jdbcType=JdbcType.LONGVARCHAR)
    })
    Hospitalization selectByPrimaryKey(String hosId);

    @UpdateProvider(type=HospitalizationSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Hospitalization record, @Param("example") HospitalizationExample example);

    @UpdateProvider(type=HospitalizationSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Hospitalization record, @Param("example") HospitalizationExample example);

    @UpdateProvider(type=HospitalizationSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Hospitalization record, @Param("example") HospitalizationExample example);

    @UpdateProvider(type=HospitalizationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Hospitalization record);

    @Update({
        "update hospitalization",
        "set hos_pet = #{hosPet,jdbcType=LONGVARCHAR},",
          "hos_record = #{hosRecord,jdbcType=LONGVARCHAR}",
        "where hos_id = #{hosId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Hospitalization record);
}